package com.sz.biz.common;

import com.sz.biz.common.constants.LanguageCode;
import com.sz.biz.logistics.constants.ProjectConstants;
import com.sz.biz.logistics.constants.ServiceConstants;
import com.sz.common.base.service.AbstractService;
import com.sz.common.core.service.PrincipalUtils;

/**
 * Function: AbstractBizService. <br>
 * Date: 2017年04月10日 15:52 <br>
 * Author: wentao.chang
 */
public abstract class AbstractBizService extends AbstractService {

    public String getStatusName(int state, Boolean isOnLine) {
        String lang = PrincipalUtils.getLocalLanguage().toLowerCase();
        if (state <= ServiceConstants.Status.AUDIT_PASS && isOnLine == null) {
            if (state == ServiceConstants.Status.DRAFTS) {
                if (LanguageCode.ZH_CN.equals(lang) ||
                        LanguageCode.ZH_TW.equals(lang) ||
                        LanguageCode.ZH_HK.equals(lang)) {
                    return "草稿";
                } else {
                    return "draft";
                }
            }
            if (state == ServiceConstants.Status.PENDING_AUDIT) {
                if (LanguageCode.ZH_CN.equals(lang)) {
                    return "待审核";
                } else if (LanguageCode.ZH_TW.equals(lang) || LanguageCode.ZH_HK.equals(lang)) {
                    return "待稽核";
                } else {
                    return "submitted";
                }
            }
            if (state == ServiceConstants.Status.AUDIT_PASS) {
                if (LanguageCode.ZH_CN.equals(lang)) {
                    return "已审核";
                } else if (LanguageCode.ZH_TW.equals(lang) || LanguageCode.ZH_HK.equals(lang)) {
                    return "已稽核";
                } else {
                    return "audited";
                }
            }
        }
        if (isOnLine != null && isOnLine) {
            if (LanguageCode.ZH_CN.equals(lang)) {
                return "已启用";
            } else {
                return "online";
            }
        }
        if (isOnLine != null && !isOnLine) {
            if (LanguageCode.ZH_CN.equals(lang)) {
                return "已停用";
            } else {
                return "offline";
            }
        }
        return "unknown";
    }

    public String getProjectStatusName(int state) {
        String lang = PrincipalUtils.getLocalLanguage().toLowerCase();

        if (state == ProjectConstants.Status.DRAFTS) {
            if (LanguageCode.ZH_CN.equals(lang) || LanguageCode.ZH_TW.equals(lang) || LanguageCode.ZH_HK.equals(lang)) {
                return "草稿";
            } else {
                return "draft";
            }
        }
        if (state == ProjectConstants.Status.PENDING_TRAL) {
            if (LanguageCode.ZH_CN.equals(lang)) {
                return "待初审";
            } else if (LanguageCode.ZH_TW.equals(lang) || LanguageCode.ZH_HK.equals(lang)) {
                return "待初審";
            } else {
                return "prepare primary audit";
            }
        }
        if (state == ProjectConstants.Status.PENDING_FINAL_APPEAL) {
            if (LanguageCode.ZH_CN.equals(lang)) {
                return "待终审";
            } else if (LanguageCode.ZH_TW.equals(lang) || LanguageCode.ZH_HK.equals(lang)) {
                return "待終審";
            } else {
                return "prepare final audit";
            }
        }

        if (state == ProjectConstants.Status.APPROVED) {
            if (LanguageCode.ZH_CN.equals(lang)) {
                return "已立项";
            } else if (LanguageCode.ZH_TW.equals(lang) || LanguageCode.ZH_HK.equals(lang)) {
                return "已立項";
            } else {
                return "approval";
            }
        }
        if (state == ProjectConstants.Status.COMPLETED) {
            if (LanguageCode.ZH_CN.equals(lang)) {
                return "已结项";
            } else if (LanguageCode.ZH_TW.equals(lang) || LanguageCode.ZH_HK.equals(lang)) {
                return "已結項";
            } else {
                return "prepare final audit";
            }
        }
        if (state == ProjectConstants.Status.CLOSED) {
            if (LanguageCode.ZH_CN.equals(lang)) {
                return "已关闭";
            } else if (LanguageCode.ZH_TW.equals(lang) || LanguageCode.ZH_HK.equals(lang)) {
                return "已關閉";
            } else {
                return "closed";
            }
        }

        return "unknown";
    }
}
